<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <a href="http://www.zhufengpeixun.cn/stu?lx=1&name=AA&age=20#teacher"></a>
    <script>
        let a = document.getElementsByTagName('a')[0]
        console.log(a.href)

        let params = a.search.substring(1) //从第一位开始截取，去除开头的?
        let hash = a.hash.substring(1) //去除开头的#
        let obj = {}
        hash ? obj['HASH'] = hash : null
        params.split('&').forEach(element => {
            let itemArr = element.split('=')
            obj[itemArr[0]] = itemArr[1]
        })
        console.log(obj)


    </script>
</body>

</html>